<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://www.codeplex.com/MSSqlSchemaDoc">

  <xsl:import href="DataType.xsl"/>
  <xsl:param name="DocumentationFile"/>

  <xsl:template match="s:Column">
    <xsl:variable name="ColName" select="@Name"/>
    
    <tr class="center">
      <td class="tablePrimaryColumn">
        <xsl:value-of select="@Name"/>
      </td>
      <td>
        <xsl:apply-templates select="s:DataType"/>
      </td>
      <td>
        <xsl:value-of select="s:IsNullable"/>
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="s:HasDefault = 'false'">No</xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="s:DefaultValue"/>
          </xsl:otherwise>
        </xsl:choose>
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="s:IsIdentity = 'false'">None</xsl:when>
          <xsl:otherwise>
            Seed:<xsl:value-of select="s:IdentitySettings/@Seed"/><br />
            Increment:<xsl:value-of select="s:IdentitySettings/@Increment"/>
          </xsl:otherwise>
        </xsl:choose>
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="s:IsComputed = 'false'">No</xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="s:ComputationSettings/@Definition"/>
            <br />
            <br />
            <xsl:choose>
              <xsl:when test="s:ComputationSettings/IsPersisted = 'false'">Not Persisted</xsl:when>
              <xsl:otherwise>
                Persisted
              </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="s:ComputationSettings/UsesDatabaseCollation = 'true'">
              <br />
              <br />
              (UsesDbCollation)
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
      </td>
      <td>
        <xsl:value-of select="s:Collation"/>
      </td>
      <td>
        <xsl:value-of select="s:IsAnsiPadded"/>
      </td>
      <td>
        <xsl:value-of select="s:IsRowGuid"/>
        </td>
      <td>
        <xsl:value-of select="s:IsFullTextIndexed"/>
      </td>
      <td>
        <table width="100%">
          <xsl:for-each select="s:IndexMembers/s:IndexMember">
            <tr class="center">
              <td>
                <xsl:value-of select="@Name"/>
              </td>
              <td>
                <xsl:choose>
                  <xsl:when test="@IsIncluded = 'true'">Included</xsl:when>
                  <xsl:otherwise>Member</xsl:otherwise>
                </xsl:choose>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </td>
      <td>
        <table width="100%">
          <xsl:for-each select="s:ForeignKeyReferences/s:ForeignKeyReference">
            <tr class="center">
              <td>
                <xsl:value-of select="@ConstraintName"/>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </td>
    </tr>
    <tr>
      <td colspan="12" class="documentation center">
        <pre>
          <xsl:value-of select="document($DocumentationFile)/s:TableDocumentation/s:Columns/s:ColumnDocumentation[@Name=$ColName]/s:Documentation"/>
          <xsl:value-of select="document($DocumentationFile)/s:ViewDocumentation/s:Columns/s:ColumnDocumentation[@Name=$ColName]/s:Documentation"/>
        </pre>
      </td>
    </tr>

  </xsl:template>
</xsl:stylesheet>